package ihm;

import java.awt.EventQueue;
import java.awt.event.ItemEvent;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import metier.Film;
import metier.Salle;
import java.awt.event.ItemListener;

public class FenetreModifSupSalle extends JInternalFrame implements ItemListener
{
	private JTextField txtNbPlaces;
	private JLabel lblNombreDePlaces;
	private JComboBox <String>lstSalle;
	private JLabel lblNumeroSalle;
	private JButton btnSupprimer;
	private JButton btnModifier;
	private Vector<Salle> lesSalles;

	/**
	 * Create the frame.
	 * @param lesSalles 
	 */
	public FenetreModifSupSalle(Vector<Salle> lesSalles)
	{
		setBounds(100, 100, 780, 478);
		getContentPane().setLayout(null);
		
		this.lesSalles = lesSalles;
		
		lstSalle = new JComboBox <String>();
		lstSalle.addItemListener(this);
		for(Salle s: lesSalles)
		{
			lstSalle.addItem(String.valueOf(s.getNumSalle()));
		}
		lstSalle.setBounds(417, 100, 50, 20);
		getContentPane().add(lstSalle);
		
		txtNbPlaces = new JTextField();
		txtNbPlaces.setBounds(381, 146, 86, 20);
		getContentPane().add(txtNbPlaces);
		txtNbPlaces.setColumns(10);
		
		lblNombreDePlaces = new JLabel("nombre de places :");
		lblNombreDePlaces.setBounds(255, 149, 128, 14);
		getContentPane().add(lblNombreDePlaces);
		
		lblNumeroSalle = new JLabel("Numero salle :");
		lblNumeroSalle.setBounds(297, 103, 86, 14);
		getContentPane().add(lblNumeroSalle);
		
		btnSupprimer = new JButton("Supprimer");
		btnSupprimer.setBounds(24, 372, 128, 23);
		getContentPane().add(btnSupprimer);
		
		btnModifier = new JButton("Modifier");
		btnModifier.setBounds(628, 372, 128, 23);
		getContentPane().add(btnModifier);
		
		chargementDonnees();

	}
	
	public void itemStateChanged(ItemEvent evt) 
	{
		   if(evt.getSource() == lstSalle)
           {
                   chargementDonnees();
           }
	}
	 public void chargementDonnees()
     {
             Salle s;
             s = (Salle) lstSalle.getSelectedItem();
             txtNbPlaces.setText(String.valueOf(s.getNbPlacesTotales()));
     }
}
